package com.example.HomeWork4.controller;

import com.example.HomeWork4.pojo.User;
import com.example.HomeWork4.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value="/list", method= RequestMethod.GET)
    public ModelAndView getList() {
        ModelAndView mav = new ModelAndView();
        List<User> userList = userService.getUserList();
        mav.addObject("userList", userList);
        mav.setViewName("list");
        return mav;
    }
}
